//
//  ProductDetailBottomView.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/21.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "ProductDetailBottomView.h"

@implementation ProductDetailBottomView

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.addCartBtn pp_clipCorners:UIRectCornerAllCorners radius:self.addCartBtn.frame.size.height/2];
        [self.buyBtn pp_clipCorners:UIRectCornerAllCorners radius:self.buyBtn.frame.size.height/2];
    });
    
    self.imControl.userInteractionEnabled = YES;
    self.cartControl.userInteractionEnabled = YES;
    
    [self.imControl addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (self.ProductDetailBottomViewBlock) {
            self.ProductDetailBottomViewBlock(ProductDetailBottomActionType_im);
        }
    }];
    
    [self.cartControl addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (self.ProductDetailBottomViewBlock) {
            self.ProductDetailBottomViewBlock(ProductDetailBottomActionType_goCart);
        }
    }];
}

- (IBAction)buyAction:(id)sender {
    if (self.ProductDetailBottomViewBlock) {
        self.ProductDetailBottomViewBlock(ProductDetailBottomActionType_buy);
    }
    
}

- (IBAction)addCartAction:(id)sender {
    if (self.ProductDetailBottomViewBlock) {
        self.ProductDetailBottomViewBlock(ProductDetailBottomActionType_addCart);
    }
}



@end
